import collections
max_range = 10 ** 5 + 1
base = 10 ** 9 + 7
jiecheng = [1] * max_range
for i in range(1, max_range):
    jiecheng[i] = jiecheng[i - 1] * i % base
niyuanjiecheng = [1] * max_range
for i in range(1, max_range):
    niyuanjiecheng[i] = niyuanjiecheng[i - 1] * pow(i, -1, base) % base
class Solution:
    def numberOfSequence(self, n: int, sick) -> int:
        m = len(sick)
        danbian = collections.defaultdict(int)
        base = 10 ** 9 + 7
        ans = 1
        for i in range(m):
            if i == 0 or i == m - 1:
                if i == 0:
                    if sick[i] > 1:
                        danbian[sick[i]] += 1
                if i == m - 1:
                    if sick[i] < n - 2:
                        danbian[n - 1 - sick[i]] += 1
            if i < m - 1:
                val = sick[i + 1] - sick[i] - 1
                if val >= 2:
                    ans = ans * pow(2, val - 1, base) % base
                    danbian[val] += 1
        total = n - m
        ans = ans * jiecheng[total] % base
        for key, val in danbian.items():
            ans = ans * pow(niyuanjiecheng[key], val, base) % base
        return ans
        

data = Solution()
n = 100000
sick = [508,8894,12669,13276,18286,26693,29021,29965,32445,39720,41902,42358,48369,51812,61508,65624,71582,76118,76557,82877]
print(data.numberOfSequence(n, sick))

                
        

